home *** CD-ROM | disk | FTP | other *** search
- var stmSBar = {
-
- onLoad: function(){
- this.register();
- },
-
- onUnLoad: function(){
- this.unregister();
- },
-
- patchSidebarURLOpen: function(pref_value) {
- switch (pref_value) {
- case true: // Open URL in new tab
- eval("PlacesUIUtils.openNodeWithEvent = " + PlacesUIUtils.openNodeWithEvent.toString().replace(
- 'this.openNodeIn(aNode, whereToOpenLink(aEvent));',
- 'this.openNodeIn(aNode, stmC.onTabSwitch("", whereToOpenLink(aEvent)));'
- ));
- break;
- case false: // Original way to open
- eval("PlacesUIUtils.openNodeWithEvent = " + PlacesUIUtils.openNodeWithEvent.toString().replace(
- 'this.openNodeIn(aNode, stmC.onTabSwitch("", whereToOpenLink(aEvent)));',
- 'this.openNodeIn(aNode, whereToOpenLink(aEvent));'
- ));
- break;
- default: // Error
- alert("unknown error: swich to default!");
- break;
- }
- },
-
- register: function() {
- var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
- this._branch = prefService.getBranch("extensions.stm.");
- this._branch.QueryInterface(Components.interfaces.nsIPrefBranch2);
- this._branch.addObserver("", this, false);
- this._branch.getChildList("", {}).forEach(function(name){
- stmSBar.observe(null, "nsPref:changed", name);
- });
- },
-
- unregister: function() {
- if(!this._branch) return;
- this._branch.removeObserver("", this);
- },
-
- observe: function(aSubject, aTopic, aData) {
- if(aTopic != "nsPref:changed") return;
- switch (aData) {
- case "openBHSInNewTab":
- var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
- this.patchSidebarURLOpen(prefs.getBoolPref("extensions.stm.openBHSInNewTab"));
- break;
- }
- }
-
- } //var end
-
- window.addEventListener("load", function(e) { stmSBar.onLoad(); }, false);
- window.addEventListener("unload", function(e) { stmSBar.onUnLoad(); }, false);
-
-
-
-
-